package com.shxzz.easy12306.services.ticket.service.handler.select;

import com.shxzz.easy12306.services.ticket.common.enums.VehicleSeatTypeEnum;
import com.shxzz.easy12306.services.ticket.common.enums.VehicleTypeEnum;
import com.shxzz.easy12306.services.ticket.service.handler.base.AbstractTrainPurchaseTicketTemplate;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * 高铁一等座选座
 *
 * @author shxzz
 * @create 2024-03-07-23:45
 */
@RequiredArgsConstructor
@Component
public class TrainFirstClassPurchaseTicketHandler extends AbstractTrainPurchaseTicketTemplate {

    /**
     * 每行座位数量
     */
    private static final int SEATS_PER_ROW = 4;
    /**
     * 车厢座位排数
     */
    private static final int ROW_NUM = 7;

    private static final Map<Character, Integer> SEAT_MAPPING = Map.of('A', 0, 'C', 1, 'D', 2, 'F', 3);
    private static final char[] SEAT_CODE = new char[]{'A', 'C', 'D', 'F'};

    @Override
    public String mark() {
        return VehicleTypeEnum.HIGH_SPEED_RAIN.getName() + VehicleSeatTypeEnum.FIRST_CLASS.getName();
    }

    @Override
    protected int getColumnIndex(Character code) {
        return SEAT_MAPPING.get(code);
    }

    @Override
    protected char getColumnCode(int colIndex) {
        return SEAT_CODE[colIndex];
    }

    @Override
    protected int getSeatsPerRow() {
        return SEATS_PER_ROW;
    }

    @Override
    protected int getRowNum() {
        return ROW_NUM;
    }

}
